<?php

namespace app\api\controller;

use app\api\controller\datas\Balance as DatasBalance;
use app\common\controller\Api;

/**
 * 余额
 * Class
 * @package app\api\controller
 */
class Balance extends Api
{

	protected $noNeedLogin = [];
	protected $noNeedRight = '*';

	/**
	 * 总余额
	 */
	public function totals()
	{
		$uid = $this->auth->id;
		$total = DatasBalance::instance()->get_totals($uid);
		$this->success("用户总余额", empty($total) ? '0.00' : $total);
	}

	/**
	 * 明细
	 */
	public function details()
	{
		$uid = $this->auth->id;
		$ret =  DatasBalance::instance()->get_details($uid);
		if ($ret === false) {
			$this->error("信息加载异常");
		}
		$this->success("账户明细", $ret);
	}

	/**
	 * 商家余额
	 */
	public function merchant_totals()
	{
		$uid = $this->auth->id;
		$ret = DatasBalance::instance()->marchent_earn($uid);
		$this->success('商家余额', $ret);
	}
}
